package org.chipu.jnids.display;

import org.chipu.jnids.alert.AlertEvent;
import org.chipu.jnids.beans.AlertGroup;

public class Message {
	public enum Type {
		DUPLICATED, IGNORED, NOT_RISK, ALERT_GROUP, ANORMAL_ACTIVITY
	}

	public final AlertEvent ev;
	public final Type type;
	public final AlertGroup ag;

	public Message(AlertEvent ev, Type type) {
		if (type == Type.ALERT_GROUP)
			throw new IllegalArgumentException("This type of message must have an AlertGroup argument");
		this.ev = ev;
		this.type = type;
		ag = null;
	}

	public Message(AlertEvent ev, Type type, AlertGroup ag) {
		this.ev = ev;
		this.type = type;
		this.ag = ag;
	}

	@Override
	public String toString() {
		String prefix;
		switch(type) {
		case DUPLICATED:
			prefix = "DUPLICATED";
			break;
		case IGNORED:
			prefix = "IGNORED";
			break;
		case NOT_RISK:
			prefix = "NOT RISK";
			break;
		case ALERT_GROUP:
			prefix = "GROUPED";
			break;
		case ANORMAL_ACTIVITY:
			prefix = "SUSPICIOUS";
			break;
		default:
			prefix = "";
		}
		return prefix + ": " + ev.toString();
	}
}